home *** CD-ROM | disk | FTP | other *** search
- unit Capform;
-
- interface
-
- uses
- {$IFDEF WIN32}
- Bde,
- {$ELSE}
- DbiErrs,
- {$ENDIF}
- Infotabs,
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,
- Controls, Forms, Dialogs, StdCtrls, Grids, DBGrids, DB, DBTables;
-
- type
-
- TDriverCapabilityForm = class(TForm)
- DriverDataSource: TDataSource;
- DriverDBGrid: TDBGrid;
- FieldTypeDBGrid: TDBGrid;
- FieldTypeDataSource: TDataSource;
- TableTypeDataSource: TDataSource;
- IndexTypeDBGrid: TDBGrid;
- DriversLabel: TLabel;
- FieldTypesLabel: TLabel;
- IndexTypesLabel: TLabel;
- TableTypeDBGrid: TDBGrid;
- TableTypesLabel: TLabel;
- IndexTypeDataSource: TDataSource;
- procedure FormCreate(Sender: TObject);
- procedure DriverDataSourceDataChange(Sender: TObject;
- Field: TField);
- private
- { Private declarations }
- DriverListTable: TDriverListTable;
- TableTypesListTable: TTableTypesListTable;
- FieldTypesListTable: TFieldTypesListTable;
- IndexTypesListTable: TIndexTypesListTable;
- public
- { Public declarations }
- end;
-
-
- var
- DriverCapabilityForm: TDriverCapabilityForm;
-
- implementation
-
- {$R *.DFM}
-
-
- procedure TDriverCapabilityForm.FormCreate(Sender: TObject);
- begin
-
- DriverListTable := TDriverListTable.Create( Self );
- DriverDataSource.DataSet := DriverListTable;
- DriverDataSource.DataSet.Open;
-
- end;
-
- procedure TDriverCapabilityForm.DriverDataSourceDataChange(
- Sender: TObject; Field: TField);
- begin
-
- if DriverDataSource.DataSet <> Nil then
- begin
-
- with DriverDataSource.DataSet do
- begin
-
- try
-
- { First close and free any existing in-memory tables. }
-
- if TableTypeDataSource.DataSet <> Nil then
- begin
- TableTypeDataSource.DataSet.Close;
- TableTypeDataSource.DataSet.Free;
- TableTypeDataSource.DataSet := Nil;
- end;
-
- if FieldTypeDataSource.DataSet <> Nil then
- begin
- FieldTypeDataSource.DataSet.Close;
- FieldTypeDataSource.DataSet.Free;
- FieldTypeDataSource.DataSet := Nil;
- end;
-
- if IndexTypeDataSource.DataSet <> Nil then
- begin
- IndexTypeDataSource.DataSet.Close;
- IndexTypeDataSource.DataSet.Free;
- IndexTypeDataSource.DataSet := Nil;
- end;
-
- { Then reopen them. }
-
- TableTypesListTable := TTableTypesListTable.Create(
- FieldByName( 'DRIVERNAME' ).AsString,
- Self
- );
- TableTypeDataSource.DataSet := TableTypesListTable;
- TableTypeDataSource.DataSet.Open;
-
- FieldTypesListTable := TFieldTypesListTable.Create(
- FieldByName( 'DRIVERNAME' ).AsString,
- Self
- );
- FieldTypeDataSource.DataSet := FieldTypesListTable;
- FieldTypeDataSource.DataSet.Open;
-
- IndexTypesListTable := TIndexTypesListTable.Create(
- FieldByName( 'DRIVERNAME' ).AsString,
- Self
- );
- IndexTypeDataSource.DataSet := IndexTypesListTable;
- IndexTypeDataSource.DataSet.Open;
-
- except
-
- on E: EDBEngineError do
- begin
- { You know what driver is creating problems...}
- with EDBEngineError(E).Errors[
- Pred(EDBEngineError(E).ErrorCount)] do
-
- begin
-
- { ...so give the user a more meaningful message.}
- if ErrorCode = DBIERR_CANTLOADLIBRARY then
- begin
- E.Message := 'Missing ' +
- FieldByName( 'DRIVERNAME' ).AsString +
- ' driver DLL';
- end
-
- else if ErrorCode = DBIERR_DRIVERNOTLOADED then
- begin
- E.Message := FieldByName( 'DRIVERNAME' ).AsString +
- ' driver not loaded';
- end; { if }
-
- end; { with EDBEngineError(E)... }
-
- { Re-reaise whatever DBEngineError was detected. }
-
- raise;
-
- end; { on EDBEngineError }
-
- end; { try ... except }
-
- end; { with DriverDataSource.DataSet }
-
- end; { if DriverDataSource.DataSet <> Nil }
-
- end;
-
- end.
-